Subject: Re: Info about _real_ semantics of hard/softlinks in AmigaOS
From: [email-masked] (Randell Jesup)
Date: 6 Feb 93 00:49:54 GMT
Newsgroups: comp.sys.amiga.programmer

[email-masked] (Lars Lundgren) writes:
>I'd like to see someone with some knowledge explain
>what hardlinks (and the rudimentary softlinks) are like
>in the present AmigaOS. As an example, I give my impression
>of the semantics of UNIX hardlinks:

>Do Amiga hardlinks break these rules? I got the impression
>by testing the other day, that the following semantics rule:
>
>x When you do a link from a to b, all you do is create
>  a copy 'b' of 'a', with just one little pecularity - it
>  doesn't occupy any disk space until you change either
>  'a' or 'b'...

	No.  They work like Unix hardlinks.  The one major difference is
that Lock()ing b, then doing NameFromLock() will give a (assuming you made
a hardlink from b to a).  We hope to eventually (not soon) remove this
difference.  Modifying the data of a or b will change it for both, just like
in Unix.

	The one problem you can have is that many editors save via: delete/
create, or rename/create/delete.  Obviously these "break" the hardlink.  If
they do an Open(...,MODE_NEWFILE), or use SetFileSize(fh,0,OFFSET_BEGINNING)
before writing the new data, then there's no problem.

>With hardlinks, you can in fact change the contents of a file
>without touching it. Will notification still work? Will I get
>notified of changes to 'a' if I change 'b'?

	Notification _should_ work, but I'm not sure it's ever been tested,
and I would actually expect some bugs given the lack of testing.  Notification
is more likely to work on hardlinks in ram:, but still no guarantee.

>What about protection bits, file dates? Are they concidered
>belonging  to the file name or to the data itself?

	The date should be shared.  The protection bits should be separate
for each link.

>Internally, AmigaDOS seems to differ files and hardlinks to files.
>If I delete the original file in this case, will the link auto-
>magically be tranformed to have the status of a real file?

	Yes.

>Softlinks. I realize that they are broken, and that implementing them
>will cause severe problems with a system with multiple filesystems
>like the Amiga. But just _how_ broken are they right now?

	They don't work in ram:.  In the ROM fs, they work to some degree
if you use absolute paths, though matchfirst/next and most dos commands can
get confused trying to deal with them.

>And why can't I get softlinks to work when part of a longer path?

	Use absolute paths when setting them up.

-- 
GNU Emacs is a LISP operating system disguised as a word processor.
 - Doug Mohney, in comp.arch

Randell Jesup, Jack-of-quite-a-few-trades, Commodore Engineering.
[email-masked]  BIX: rjesup  
Disclaimer: Nothing I say is anything other than my personal opinion.